{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<div class="tablesWrap">  
<!-- end tables-searchbox -->  
<table class="wxtables">  
    <colgroup>  
    <col width="10%">
    <col width="10%">
    <col width="10%">
    <col width="20%">
    <col width="10%">
    <col width="10%">
    <col width="10%">
    <col width="20%">
    </colgroup>
    <thead>
        <tr>  
            <td>选择</td>  
            <td>视频名称</td>
            <td>所属频道</td>
            <td>视频封面</td>
            <td>价格</td>
            <td>排序号</td>
            <td>是否显示</td>
            <td>操作</td>
        </tr>  
    </thead>  
	{foreach from=$live_list item=this}
    <tbody class="combo-tbody">  
        <tr>
			<td><input type="checkbox" class="checkbox" name="a[]" value="{$this.live_id}"></td>
			<td>{$this.live_name}</td>
			<td>{$this.class_name}</td>
			<td><img src="{$this.pic}" style="width:80px;"></td>
			<td>{$this.price}</td>
			<td>{$this.serial}</td>
			<td>{if $this.isuse == 1}是{else}否{/if}</td>
            <td>
            	<!--<a href="javascript:;" class="btn" onclick='class_link({$this.live_id})' title="复制链接">复制链接</a>-->
				<a href="/AcpLive/add_edit_live/live_id/{$this.live_id}.html" class="btn" title="修改">修改</a>
        <a href="javascript:;" class="btn" title="删除" onclick="delete_obj({$this.live_id})">删除</a>
            </td>  
        </tr>
    </tbody>
	{foreachelse}   
    <tbody>    
		<tr>
			<td colspan="7">
				没有符合条件的记录
			</td>
		<tr>
    </tbody>  
	{/foreach}
</table>  
<!-- end wxtables -->  
<div class="tables-btmctrl clearfix">  
    <div class="fl">  
        <a href="javascript:;" class="btn btn-blue" onclick="Select()">全选</a>  
        <a href="javascript:;" class="btn btn-blue" onclick="Cancel()">取消</a>  
        <a href="javascript:;" onclick="batch_delete_obj()" class="btn btn-blue">删除</a>
    </div>  
    <div class="fr">  
        <div class="paginate">
			{$page_str} 
        </div>  
        <!-- end paginate -->  
    </div>  
</div>  
<!-- end tables-btmctrl -->  
</div>  
<!-- end tablesWrap -->   
{/block} 

{block name="js"}
<script src="/Public/Plugins/My97DatePicker/WdatePicker.js?version={$version}"></script>
<script src="__JS__/clipboard.min.js"></script>
{literal}
<script>
	//全选
	function Select(){
		var sel=document.getElementsByName("a[]");
		for(var i=0;i<sel.length;i++){
			sel[i].checked=true;
		}
	}
	//取消全选
	function Cancel(){
		var sel=document.getElementsByName("a[]");
		for(var i=0;i<sel.length;i++){
			sel[i].checked=false;
		}
	}

    function delete_obj(obj_id) {
        $.jPops.confirm(
                {
                    title: "提示",
                    content: "您确定要删除这条数据吗？",
                    okBtnTxt: "确定",
                    cancelBtnTxt: "取消",
                    callback: function (r) {
                        if (r) {
                            $.post('/AcpLive/batch_delete_live', {"obj_ids": obj_id}, function (data, textStatus) {
                                if (data == 'success') {
                                    alert('恭喜您，删除成功！');
                                    location.reload();
                                }
                                else {
                                    alert('对不起，删除失败！');
                                }
                            });
                        }
                        return true;
                    }
                });
    }

    function batch_delete_obj() {
        $.jPops.confirm(
                {
                    title: "提示",
                    content: "您确定要删除这些数据吗？",
                    okBtnTxt: "确定",
                    cancelBtnTxt: "取消",
                    callback: function (r) {
                        if (r) {
                            var obj_ids = '';
                            var count = 0;
                            $('input[name="a[]"]:checked').each(function () {
                                count++;
                                obj_ids += $(this).val() + ',';
                            });

                            if (!count) {
                                alert('对不起，请选择至少一项进行删除！');
                                return;
                            }

                            obj_ids = obj_ids.substr(0, obj_ids.length - 1);

                            $.post('/AcpLive/batch_delete_live', {"obj_ids": obj_ids}, function (data, textStatus) {
                                if (data == 'success') {
                                    alert('恭喜您，删除成功！');
                                    location.reload();
                                }
                                else {
                                    alert('对不起，删除失败！');
                                }
                            });
                        }
                        return true;
                    }
                });
    }
//复制商品链接
function class_link(class_id)
{
    var link = 'http://' + document.domain + '/FrontMall/item_list/class_id/' + class_id;
    $.jPops.custom({
        title:"请复制链接",  
        content:'<div>一级分类链接：' + link + '</div>',
        okBtnTxt:"复制",  
        cancelBtnTxt:"关闭",  
        callback:function(r)
        {
            if(r)
            {
                text = link;
                copy_text('jpops-btn-ok');
            }
            else
            {
                return true;  
            }
        }
    });
}
function copy_text(id)
    {
        var clipboard = new Clipboard('#' + id, {
            text: function() {
                return text;
            }
        });

        clipboard.on('success', function(e) {
            console.log(e);
            alert('复制成功');
        });

        clipboard.on('error', function(e) {
            console.log(e);
            alert('复制失败，请手动复制');
        });
    }
</script>
{/literal}
{/block} 

{block name="css"}
<link type="text/css" rel="stylesheet" href="__ACPCSS__/tip.css" />
{literal}
<style>
.PageNext{page-break-after: always; height:1px;}
</style>
{/literal}
{/block} 
